package com.ccom.ccomstart.controller;

import com.alibaba.fastjson.JSONObject;
import com.ccom.ccomstart.domain.User;
import com.ccom.ccomstart.mapper.UserMapper;
import com.ccom.ccomstart.service.OpenOfficeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * @author zjj
 * @date 2021/9/29 10:13
 * @description
 */
@RestController
@RequestMapping(value = "/test")
public class TestController {
    @Autowired
    private UserMapper userMapper;

    @Autowired
    private OpenOfficeService officeService;

    @GetMapping("/get")
    public String getUser() {
        User user = userMapper.selectById(1);
        return JSONObject.toJSONString(user);
    }

    @ApiOperation(value = "系统文件在线预览接口")
    @PostMapping("/api/file/onlinePreview")
    public void onlinePreview(@RequestParam("url") String url, HttpServletResponse response) throws Exception {
        officeService.onlinePreview(url, response);
    }
}
